package cn.seaboot.admin.user.authority;

import cn.seaboot.admin.user.bean.UserDept;
import cn.seaboot.admin.user.service.UserDeptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户分组 @author Mr.css on 2018-6-20
 */
@Controller
@Tag(name = " 用户分组 [t_sys_user_dept] 管理")
@RequestMapping("authority/dept")
public class UserDeptAuthorityCtrl {

    @Resource
    private UserDeptService userGroupService;

    /**
     * 分组目录
     */
    @ResponseBody
    @Operation(description = " 用户分组 [t_sys_user_dept] 查询所有节点")
    @RequestMapping(value = "fully", method = RequestMethod.GET)
    public List<UserDept> fully() {
        return userGroupService.selectList();
    }

    /**
     * 分组目录
     */
    @ResponseBody
    @Operation(description = " 用户分组 [t_sys_user_dept] 查询父级节点")
    @RequestMapping(value = "parent", method = RequestMethod.GET)
    public List<UserDept> parent() {
        return userGroupService.selectList();
    }

    /**
     * 分组目录
     */
    @ResponseBody
    @Operation(description = " 用户分组 [t_sys_user_dept] 查询子级节点")
    @RequestMapping(value = "children", method = RequestMethod.GET)
    public List<UserDept> children() {
        return userGroupService.selectList();
    }

    /**
     * 分组目录
     */
    @ResponseBody
    @Operation(description = " 用户分组 [t_sys_user_dept] 查询先辈节点")
    @RequestMapping(value = "ancestor", method = RequestMethod.GET)
    public List<UserDept> ancestor() {
        return userGroupService.queryAbove();
    }

    /**
     * 分组目录
     */
    @ResponseBody
    @Operation(description = " 用户分组 [t_sys_user_dept] 查询平级和下级分组")
    @RequestMapping(value = "node", method = RequestMethod.GET)
    public List<UserDept> horizon() {
        return userGroupService.queryNode();
    }

    /**
     * 分组目录
     */
    @ResponseBody
    @Operation(description = " 用户分组 [t_sys_user_dept] 查询同胞节点")
    @RequestMapping(value = "sibling", method = RequestMethod.GET)
    public List<UserDept> sibling() {
        return userGroupService.querySibling();
    }

    /**
     * 分组目录
     */
    @ResponseBody
    @Operation(description = " 用户分组 [t_sys_user_dept] 查询后代节点")
    @RequestMapping(value = "descendant", method = RequestMethod.GET)
    public List<UserDept> descendant() {
        return userGroupService.queryDescendant();
    }
}
